import {
    bannerList,bannerInfo,
} from "../../request/api"

const state = {
    bannerList: [],
    bannerInfo:{}
}
//导出
const getters = {
    bannerList(state) {
        return state.bannerList
    },
    bannerInfo(state) {
        return state.bannerInfo
    },
}
//修改
const mutations = {
    cBannerList(state, data) {
        state.bannerList = data;
    },
    cBannerInfo(state, data) {
        state.bannerInfo = data;
    },
}
// 异步逻辑
const actions = {
    reqBannerList(context) {
        bannerList().then(res => { 
            context.commit("cBannerList", res.data.list)
        })
    },
    reqBannerInfo(context,data) {
        bannerInfo({id:data}).then(res => { 
            res.data.list.id = data
            console.log(res.data.list);
            context.commit("cBannerInfo", res.data.list)
        })
    },
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}